package com.ruima.study.arithmetic.law;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * <p></p>
 * <p>
 * <p>Copyright (c) 2024/11/22 10:58, 科大讯飞 All Rights Reserve</p>
 *
 * @author ruima6
 * @version [V1.0]
 */
public class Demo2 {
    public static Boolean isLx(int[] arr){
        Boolean tag = true;
        int zeroCount = 0;
        int min = arr[0];
        Map<Integer, Boolean> map = new HashMap<>();

        for (int i : arr) {
            if (i == 0) {
                zeroCount++;
                continue;
            }
            if (i < min){
                min = i;
            }
            map.put(i, true);
        }

        for (int i = 1; i < (arr.length - zeroCount); i++) {
            if (!map.containsKey(i + min)) {
                if (zeroCount > 0) {
                    zeroCount--;
                } else {
                    tag = false;
                    break;
                }
            }
        }
        return tag;
    }
}
